// Copyright 2023 Huawei Cloud Computing Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package com.android.cloudapp;

public class CloudAppMsg {
    public static final short HEARTBEAT_MSG_ID = 0;
    public static final short DATA_MSG_ID = 1;
    public static final int MSG_HEADER_LEN = 6;
    public static final  short MSG_MAGICWORD = 0x5A5A;

    public static class CloudAppMsgHeader {
        private final short mMsgId;
        private final short mMsgBodyLen;
        private final short mMagicWord;

        public CloudAppMsgHeader (byte[] data) {
            this.mMsgId = (short) ((data[0] << 8) | data[1] & 0x0FF);
            this.mMsgBodyLen = (short) ((data[2] << 8) | data[3] & 0x0FF);
            this.mMagicWord = (short) ((data[4] << 8) | data[5] & 0x0FF);
        }

        public short getmMsgId() {
            return mMsgId;
        }

        public short getmMsgBodyLen() {
            return mMsgBodyLen;
        }

        public short getmMagicWord() {
            return mMagicWord;
        }
    }
}
